<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
      <a-button v-if="!disableSubmit" type="primary" @click="handleOk" :loading="buttonok">确定</a-button>
    </template>
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row>
          <a-col :span="12">
            <a-form-item label="花名册" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-search-select-tag
                :disabled="disableSubmit"
                @change="selectWxUserId"
                v-decorator="['wxUserId']"
                dict="HrWxUser,name,userId,"
                otherField="mobile,gender,email,avatar,thumbAvatar,position,telephone,alias,address,englishName"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="员工姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['name', validatorRules.name]"
                placeholder="请输入员工姓名"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="英文名" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" v-decorator="['nameEn']" placeholder="请输入英文名"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['gender', validatorRules.gender]"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =USER_SEX"
                placeholder="请选择性别"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="年龄" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number
                :disabled="disableSubmit"
                v-decorator="['age', validatorRules.age]"
                placeholder="请输入年龄"
                style="width: 100%"
              ></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="出生日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                :disabled="disableSubmit"
                placeholder="请选择出生日期"
                v-decorator="['birthday', validatorRules.birthday]"
                :trigger-change="true"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="身份证" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['idCard', validatorRules.idCard]"
                placeholder="请输入身份证"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="婚姻状况" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['wedlock', validatorRules.wedlock]"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =EMP_MARITAL_STATUS"
                placeholder="请选择婚姻状况"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="民族" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-search-select-tag
                :disabled="disableSubmit"
                v-decorator="['nationId', validatorRules.nationId]"
                dict="DataDictionary,description,dictionaryCode, dictionaryTypeId =ETHNICITY"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="籍贯" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['nativePlace', validatorRules.nativePlace]"
                placeholder="请输入籍贯"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="政治面貌" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['politicId']"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =EMP_PARTY"
                placeholder="请选择政治面貌"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['email', validatorRules.email]"
                placeholder="请输入邮箱"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="电话号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['phone', validatorRules.phone]"
                placeholder="请输入电话号码"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="联系地址" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" v-decorator="['address']" placeholder="请输入联系地址"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="所属部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-category-select
                :disabled="disableSubmit"
                v-decorator="['departmentId', validatorRules.departmentId]"
                pcode="{table:'HrDepartment',txt:'name',key:'departmentId',idField:'id',pidField:'parentId',hasChildField:'hasChild', condition:' parentId = 0'}"
                placeholder="请选择所属部门"
                back="title"
                @change="handleCategoryChange"
              />
            </a-form-item>
          </a-col>
           <a-col :span="12">
            <a-form-item label="职级" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['positionRank', validatorRules.positionRank]"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =POSITION_RANK"
                placeholder="请选择职级"
              />
            </a-form-item>
          </a-col>
           <a-col :span="12">
            <a-form-item label="岗位" :labelCol="labelCol" :wrapperCol="wrapperCol">
               <a-input
                :disabled="disableSubmit"
                v-decorator="['positionName']"
                placeholder="请输入岗位"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="职称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['jobLevelId', validatorRules.jobLevelId]"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =JOB_LEVEL"
                placeholder="请选择职称"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="聘用形式" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['engageForm']"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =WORK_TYPE"
                placeholder="请选择聘用形式"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="管培生" :labelCol="labelCol" :wrapperCol="wrapperCol">
             <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['isGuanPeiSheng']"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId = BOOL_DEFINE"
                placeholder="请选择"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="最高学历" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['tiptopDegree', validatorRules.tiptopDegree]"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId = EMP_EDUCATION"
                placeholder="请选择最高学历"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="所属专业" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['specialty', validatorRules.specialty]"
                placeholder="请输入所属专业"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="毕业院校" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['school', validatorRules.school]"
                placeholder="请输入毕业院校"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="工龄" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['workAge']"
                placeholder="请输入工龄"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="入职日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                :disabled="disableSubmit"
                placeholder="请选择入职日期"
                v-decorator="['beginDate', validatorRules.beginDate]"
                :trigger-change="true"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="在职状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['workState']"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =EMP_WORK_STATE"
                placeholder="请选择在职状态"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="工号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" v-decorator="['workId']" placeholder="请输入工号"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="合同关系公司" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['companyName']"
                placeholder="请输入合同关系公司"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="合同期限(年)" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <!-- <a-input
                :disabled="disableSubmit"
                v-decorator="['contTerm', validatorRules.contTerm]"
                placeholder="请输入合同期限"
              ></a-input> -->
              <a-input-number :disabled="disableSubmit" v-decorator="['contTerm', validatorRules.contTerm]" placeholder="请输入合同期" style="width: 100%"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="转正日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                :disabled="disableSubmit"
                placeholder="请选择转正日期"
                v-decorator="['conversionTime']"
                :trigger-change="true"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="离职日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                :disabled="disableSubmit"
                placeholder="请选择离职日期"
                v-decorator="['notWorkDate']"
                :trigger-change="true"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="合同起始日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                :disabled="disableSubmit"
                placeholder="请选择合同起始日期"
                v-decorator="['beginContract', validatorRules.beginContract]"
                :trigger-change="true"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="合同终止日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                :disabled="disableSubmit"
                placeholder="请选择合同终止日期"
                v-decorator="['endContract']"
                :trigger-change="true"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="户籍类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                :disabled="disableSubmit"
                type="list"
                v-decorator="['household']"
                :trigger-change="true"
                dictCode="DataDictionary,description,dictionaryCode, dictionaryTypeId =HOUSEHOLD"
                placeholder="请选择户籍类型"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="户籍所在地" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['householdLocation']"
                placeholder="请输入户籍所在地"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="工作地点" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" v-decorator="['workAddress']" placeholder="请输入工作地点"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="直属上级" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" v-decorator="['reportTo']" placeholder="请输入直属上级"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="预计入职日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                :disabled="disableSubmit"
                placeholder="请选择预计入职日期"
                v-decorator="['estimateBeginDate']"
                :trigger-change="true"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="银行卡号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" v-decorator="['bankCard']" placeholder="请输入银行卡号"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="开户行" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" v-decorator="['bankOfDeposit']" placeholder="请输入开户行"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="紧急联系人" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['emergencyContact']"
                placeholder="请输入紧急联系人"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="联系人关系" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['contactRelationship']"
                placeholder="请输入联系人关系"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="联系人电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                :disabled="disableSubmit"
                v-decorator="['contactNumber', validatorRules.contactNumber]"
                placeholder="请输入联系人电话"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-upload :disabled="disableSubmit" :isMultiple="false" v-decorator="['uploadPath']" :trigger-change="true"></j-upload>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="学历证书" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-image-upload :disabled="disableSubmit" isMultiple v-decorator="['personalMaterial']"></j-image-upload>
            </a-form-item>
          </a-col>
          <a-form-item v-show="false">
            <a-input :disabled="disableSubmit" v-decorator="['name']"></a-input>
          </a-form-item>
        </a-row>
      </a-form>
    </a-spin>
  </j-modal>
</template>

<script>
import { httpAction } from '@/api/manage'
import pick from 'lodash.pick'
import { validateDuplicateValue } from '@/utils/util'
import JDate from '@/components/jeecg/JDate'
import JUpload from '@/components/jeecg/JUpload'
import JImageUpload from '@/components/jeecg/JImageUpload'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
import JCategorySelect from '@/components/jeecg/JCategorySelect'

export default {
  name: 'HrEmployeeModal',
  components: {
    JDate,
    JUpload,
    JImageUpload,
    JDictSelectTag,
    JSearchSelectTag,
    JCategorySelect,
  },
  data() {
    return {
      disableSubmit: false,
      form: this.$form.createForm(this),
      title: '操作',
      width: 950,
      visible: false,
      buttonok: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        wxUserId: {
          rules: [{ required: true, message: '请输入花名册的ID!' }],
        },
        typeId: {
          rules: [{ required: true, message: '请输入类型!' }],
        },
        name: {
          rules: [{ required: true, message: '请输入员工姓名!' }],
        },
        /* nameEn: {
            rules: [
              { required: true, message: '请输入英文名!'},
            ]
          }, */
        gender: {
          rules: [{ required: true, message: '请输入性别!' }],
        },
        /*age: {
          rules: [{ required: true, message: '请输入年龄!' }],
        },
         birthday: {
          rules: [{ required: true, message: '请输入出生日期!' }],
        }, */
        idCard: {
          rules: [{ required: true, message: '请输入身份证!' }],
        },
        /* wedlock: {
          rules: [{ required: true, message: '请输入婚姻状况!' }],
        }, */
        nationId: {
          rules: [{ required: true, message: '请输入民族!' }],
        },
        nativePlace: {
          rules: [{ required: true, message: '请输入籍贯!' }],
        },
        email: {
          rules: [
            { required: true, message: '请输入邮箱!' },
            { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!' },
          ],
        },
        phone: {
          rules: [
            { required: true, message: '请输入电话号码!' },
            { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!' },
          ],
        },
        departmentId: {
          rules: [{ required: true, message: '请输入所属部门!' }],
        },
        positionRank: {
          rules: [{ required: true, message: '请选择职级!' }],
        },
        jobLevelId: {
          rules: [{ required: true, message: '请输入职称ID!' }],
        },
        engageForm: {
          rules: [{ required: true, message: '请输入聘用形式!' }],
        },
        tiptopDegree: {
          rules: [{ required: true, message: '请输入最高学历!' }],
        },
        specialty: {
          rules: [{ required: true, message: '请输入所属专业!' }],
        },
        school: {
          rules: [{ required: true, message: '请输入毕业院校!' }],
        },
        workAge: {
          rules: [{ required: true, message: '请输入工龄!' }],
        },
        beginDate: {
          rules: [{ required: true, message: '请输入入职日期!' }],
        },
        workState: {
          rules: [{ required: true, message: '请输入在职状态!' }],
        },
        /* workId: {
            rules: [
              { required: true, message: '请输入工号!'},
            ]
          }, */
        contTerm: {
          rules: [{ required: true, message: '请输入合同期限!' }],
        },
        /* conversionTime: {
            rules: [
              { required: true, message: '请输入转正日期!'},
            ]
          }, */
        beginContract: {
          rules: [{ required: true, message: '请输入合同起始日期!' }],
        },
        endContract: {
          rules: [{ required: true, message: '请输入合同终止日期!' }],
        },
        household: {
          rules: [{ required: true, message: '请输入户籍类型!' }],
        },
        householdLocation: {
          rules: [{ required: true, message: '请输入户籍所在地!' }],
        },
        estimateBeginDate: {
          rules: [{ required: true, message: '请输入预计入职日期!' }],
        },
        /* bankCard: {
            rules: [
              { required: true, message: '请输入银行卡号!'},
            ]
          }, 
          bankOfDeposit: {
            rules: [
              { required: true, message: '请输入开户行!'},
            ]
          },*/
        contactNumber: {
          rules: [{ pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!' }],
        },
      },
      url: {
        add: '/online/api/createHrEmployee',
        edit: '/online/api/updateHrEmployee',
        get: '/online/api/getHrEmployee',
      },
    }
  },
  created() {},
  methods: {
    add() {
      this.edit({})
    },
    edit(record) {
      this.form.resetFields()
      this.visible = true
      this.model = {}
      if (record.partyId) {
        httpAction(this.url.get, { partyId: record.partyId }, 'post').then((res) => {
          if (res.success) {
            this.model = Object.assign({}, res.result)
            this.$nextTick(() => {
              this.form.setFieldsValue(
                pick(
                  this.model,
                  'wxUserId',
                  'name',
                  'nameEn',
                  'gender',
                  'age',
                  'birthday',
                  'idCard',
                  'wedlock',
                  'nationId',
                  'nativePlace',
                  'politicId',
                  'email',
                  'phone',
                  'address',
                  'departmentId',
                  'positionRank',
                  'positionName',
                  'jobLevelId',
                  'engageForm',
                  'isGuanPeiSheng',
                  'tiptopDegree',
                  'specialty',
                  'school',
                  'personalMaterial',
                  'workAge',
                  'beginDate',
                  'workState',
                  'workId',
                  'companyName',
                  'contTerm',
                  'conversionTime',
                  'notWorkDate',
                  'beginContract',
                  'endContract',
                  'uploadPath',
                  'household',
                  'householdLocation',
                  'workAddress',
                  'reportTo',
                  'estimateBeginDate',
                  'bankCard',
                  'bankOfDeposit',
                  'emergencyContact',
                  'contactRelationship',
                  'contactNumber'
                )
              )
            })
          }
        })
      }
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true
          that.buttonok = true
          let httpurl = ''
          let method = ''
          if (!this.model.partyId) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          let formData = Object.assign(this.model, values)
          formData.typeId = 'EMPLOYEE'
          //新添加的员工设置待认证
          if (method == 'post') {
            formData.legalStatusId = 'LEGAL_APPLY'
          }
          console.log('表单提交数据', formData)
          httpAction(httpurl, formData, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
              setTimeout(() => { that.buttonok = false; }, 500);
            })
            .finally(() => {
              that.confirmLoading = false
              that.close()
            })
        }
      })
    },
    handleCancel() {
      this.close()
    },
    popupCallback(row) {
      this.form.setFieldsValue(
        pick(
          row,
          'wxUserId',
          'name',
          'nameEn',
          'gender',
          'age',
          'birthday',
          'idCard',
          'wedlock',
          'nationId',
          'nativePlace',
          'politicId',
          'email',
          'phone',
          'address',
          'departmentId',
          'positionRank',
          'positionName',
          'jobLevelId',
          'engageForm',
          'isGuanPeiSheng',
          'tiptopDegree',
          'specialty',
          'school',
          'personalMaterial',
          'workAge',
          'beginDate',
          'workState',
          'workId',
          'companyName',
          'contTerm',
          'conversionTime',
          'notWorkDate',
          'beginContract',
          'endContract',
          'uploadPath',
          'household',
          'householdLocation',
          'workAddress',
          'reportTo',
          'estimateBeginDate',
          'bankCard',
          'bankOfDeposit',
          'emergencyContact',
          'contactRelationship',
          'contactNumber'
        )
      )
    },
    handleCategoryChange(value, backObj) {
      this.form.setFieldsValue(backObj)
    },
    selectWxUserId(val, row) {
      //this.model.name = row.name
      this.model.nameEn = row.englishName
      this.model.mobile = row.mobile
      this.model.address = row.address
      //this.model.email = row.email
      this.model.logoImageUrl = row.avatar
      this.model.nickName = row.alias
      this.visible = true
      let fieldval = pick(this.model, 'name', 'nameEn', 'mobile', 'address', 'email', 'logoImageUrl', 'nickName')
      this.$nextTick(() => {
        this.form.setFieldsValue(fieldval)
      })
    },
  },
}
</script>
